package com.ruoyi.archives.utile;

import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :GzhAnkh
 * @create :2022-03-06 17:56:00
 */
@RestController
public class DirectorRoleUtile {

    @Autowired
    private SysRoleMapper sysRoleMapper;

    public int getSTDirectorRole(LoginUser loginUser) {
        List<SysRole> sysRoles = sysRoleMapper.selectRolesByUserName(loginUser.getUsername());
        int flag=1;
        for (SysRole sysRole : sysRoles) {
            if (sysRole.getRoleKey().equals("studentDirector")||sysRole.getRoleKey().equals("allDirector")) {
                flag = 0;
                break;
            }
        }
        return flag;
    }

    public int getTEDirectorRole(LoginUser loginUser) {
        List<SysRole> sysRoles = sysRoleMapper.selectRolesByUserName(loginUser.getUsername());
        int flag=1;
        for (SysRole sysRole : sysRoles) {
            if (sysRole.getRoleKey().equals("teacherDirector")||sysRole.getRoleKey().equals("allDirector")) {
                flag = 0;
                break;
            }
        }
        return flag;
    }
}
